require([
	'jquery',
	'module/util',
	'module/popup',
	'global',
	'datatables.fixedcolumns',
	'requirejs/domready!'],
function($, util, popup, g){
	var table = null;
	// 渲染表格
	$('#log-table').on('click', 'tbody td', function(){
		var dt = $('#log-table').dataTable().api();
		var idx = dt.cell(this).index();
		if(!idx) return;
		var row = dt.row(idx.row).data();
		$(this).parents('tbody').find('tr.selected').removeClass('selected');
		$(this).parent().addClass('selected');
	}).on('draw.dt', function(){
    	if(table){
    		table.columns.adjust();
    	}
    }).dataTable( {
    	language: {
            url: g.context + '/assets/js/chinese.json'
        },
        dom: 'rt<"row"<"col-md-4"i><"col-md-8"p>>',
    	processing : true,
	    serverSide : true,
	    ajax: {
	    	type: 'POST',
	    	url: g.context + '/admin/logs',
	    	contentType: 'application/json; charset=utf-8',
	    	global: false,
	    	data: function(d){
	    		return JSON.stringify(d);
	    	},
	    	error: function(xhr, status, error){
	    		console.log(error);
	    	}
	    },
	    columnDefs: [ 
	     	{ targets : ['_all'], defaultContent: '&nbsp;', searchable : false }
	    ],
	    columns: [
	        { data: 'log'},
	        { data: 'createdBy'},
	        { data: 'createdAt'},
	    ]
    });
	table = $('#log-table').dataTable().api();
});